namespace ghost {
	/**角色配置**/
	export class RoleConfig {
		private static _roleConfig:any={};
		private static _objConfig:any={};
		public static setRoleConfig(arr:any[]):void
		{
			RoleConfig._roleConfig = arr;
		}
		public static setObjConfig(arr:any[]):void
		{
			RoleConfig._objConfig = arr;
		}
		private static createObjRoleConfig(objID: string, smart: AIEnum, layerType:number=NaN): any {
			let obj: any;
			if (RoleConfig._objConfig[objID])
				return RoleConfig._objConfig[objID];
			// if (DEBUG) {
			// 	if (Conf._objConfig[objID] == null)
			// 		GlobalData.throwError("找不到物体：objID=" + objID);
			// }
			if (GameManager.debug) {
				if (RoleConfig._objConfig[objID]) {
					console.error("导入重复的物体:" + "objID=" + objID);
				}
			}
			obj = {
				id: objID,
				smart: smart,
				roleID: objID,
				roleType: RoleType.DRIFT_OBJ,
				layerType: layerType == layerType?layerType:map2D.LayerType.ROLE,
				areaRect: [-64, -64, 128, 128],
				skin: {
					skinType: SkinType.SEQ,
					clothes: objID,
					action: objID
				},
				disposed: false,
				dispose() {
					if (this.disposed) return;
					this.disposed = true;
				},
			};
			RoleConfig._objConfig[objID] = obj;
			return obj;
		}
		/**特效角色（如建筑、迷雾等）*/
		public static createEffRoleCfg(roleID: number, modelID: number = -1, roleName: string = null): any {
			// let dict: any = RoleConfig.getRoleDict(gameRoleType);
			// if (dict[roleID]) {
			// 	console.error((gameRoleType ? gameRoleType._name : "") + "表导入重复的特效角色:" + "roleID=" + roleID);
			// 	return null;
			// }
			// let table: edc.GameTable = ConfigMgr.getTable(TableEnum.effect);
			let obj: any;
			obj = {
				id: roleName,
				roleID: String(roleID),
				skin: {
					scale: 1,
					skinType: SkinType.SEQ,
					clothes: String(modelID),
					action: String(modelID)
				},
				disposed: false,
				dispose() {
					if (this.disposed) return;
					this.disposed = true;
				},
			};
			// table.dispatcher.bind(String(modelID), EffectCfg.effModelDataSet, obj);
			return obj;
		}
		public static createEffectConfigByLayer(effectID: string, layerType: map2D.LayerType): any {
			if (RoleConfig._objConfig[effectID])
				return RoleConfig._objConfig[effectID];
			// if (GameManager.debug) {
			// 	if (ClothesConfig.effectResource[effectID] == null) {
			// 		console.error("找不到特效：effectID=" + effectID);
			// 		return null;
			// 	}
			// }
			let effectCfg: any = {
				id: effectID,
				roleID: effectID,
				roleType: RoleType.EFFECT,
				layerType: layerType,
				areaRect: [-337 / 2, -173 / 2, 337, 173],
				skin: {
					skinType: SkinType.SEQ,
					clothes: effectID,
					action: effectID
				}
			};
			RoleConfig._objConfig[effectID] = effectCfg;
			return effectCfg;
		}
		/**根据effectID获取特效配置，如不存在，则根据layerType创建一个*/
		public static getEffectObj(effectType:EffectType, effectID: string, layerType: number, check: boolean = false): any {
			let effectCfg: any;
			effectCfg = RoleConfig.getObjConfig(effectID);			
			if (effectCfg == null) {
				if (layerType == map2D.LayerType.ROLE || effectType == EffectType.ATTACK)//攻击特效必须是飞行物
					effectCfg = RoleConfig.createObjRoleConfig(effectID, AIEnum.TargetSmart, layerType);
				else
					effectCfg = RoleConfig.createEffectConfigByLayer(effectID, layerType);
			}
			else if (layerType == layerType)
				effectCfg.layerType = layerType;
			return effectCfg;
		}
		public static getRoleConfig(roleID:string):any
		{
			if(RoleConfig._roleConfig[roleID])
				return RoleConfig._roleConfig[roleID];
			let obj:any;
			if(roleID == "1")
			{
				obj = {
					id:"player",
					roleID:roleID,
					smart:"autoShoot",
					roleType:RoleType.PLAYER,
					roleListType:RoleListType.PLAYER,	
					skin:{
						skinType:SkinType.SEQ,										
						clothes:"1",
						action:"1"
					}
				};	
			}
			else if(roleID == "101")
			{
				obj = {
					id:"monster101",
					roleID:roleID,		
					smart:"monsterSmart",								
					roleType:RoleType.MONSTER,
					roleListType:RoleListType.MONSTER,	
					areaRect:[-150,-150,300,300],	
					skin:{
						skinType:SkinType.SEQ,										
						clothes:"101",
						action:"101"
					}
				};	
			}
			else if(roleID == "102")
			{
				obj = {
					id:"monster102",
					roleID:roleID,
					smart:"monsterSmart",
					roleType:RoleType.MONSTER,
					roleListType:RoleListType.MONSTER,	
					areaRect:[-150,-150,300,300],	
					skin:{
						skinType:SkinType.SEQ,										
						clothes:"102",
						action:"102"
					}
				};	
			}
			else if(roleID == "103")
			{
				obj = {
					id:"monster103",
					roleID:roleID,
					smart:"monsterSmart",
					roleType:RoleType.MONSTER,
					roleListType:RoleListType.MONSTER,	
					areaRect:[-150,-150,300,300],	
					skin:{
						skinType:SkinType.SEQ,										
						clothes:"103",
						action:"103"
					}
				};	
			}
			
			RoleConfig._roleConfig[roleID] = obj;
			return obj;
		}
		public static getObjConfig(objID:string):any
		{
			if(RoleConfig._objConfig[objID])
				return RoleConfig._objConfig[objID];
			let obj:any;
			// if(objID == "100001")
			// {
			// 	obj = {
			// 		id:"bullet1",					
			// 		smart:"bulletSmart",					
			// 		roleID:objID,
			// 		roleType:RoleType.DRIFT_OBJ,	
			// 		roleListType:RoleListType.DRIFT_OBJ,					
			// 		areaRect:[-72/2,-80/2,72,80],			
			// 		skin:{
			// 			skinType:SkinType.SEQ,										
			// 			clothes:objID,
			// 			action:objID
			// 		}
			// 	};
			// }

			RoleConfig._objConfig[objID] = obj;
			return obj;
		}
	}
}